<template>
  <div>
    <el-container>
      <el-main>
        <el-table :data="user" style="width: 100%">
          <el-table-column label="id" prop="id"></el-table-column>
          <el-table-column label="用户名" prop="number"></el-table-column>
<!--          <el-table-column label="押金状态" prop="auth == 1 ? 是:否"></el-table-column>-->
          <el-table-column label="学校" prop="school"></el-table-column>
          <el-table-column>
            <template slot-scope="user">
              <el-button @click="deleteUser(user.row.id)" type="danger">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-main>
<!--      <el-footer>-->
<!--        <div class="floor">-->
<!--          <el-pagination-->
<!--            background-->
<!--            layout="prev, pager, next"-->
<!--            :total="0">-->
<!--          </el-pagination>-->
<!--          <el-button type="primary" @click="addButton">添加<i class="el-icon-plus el-icon&#45;&#45;right"></i></el-button>-->
<!--        </div>-->
<!--      </el-footer>-->
    </el-container>
  </div>
</template>

<script>
  import { getList,insertOne,delByid, update } from "@/api/roles";
  import {ApiService} from "@/api/apiService";
  export default {
  name: 'Role',
  data(){
    return {
      user:[],
    }
  },
  mounted() {
    this.getAlluser();
  },

    methods: {
    getAlluser() {
      const api = new ApiService("/user/all")
      api.get().then(res => {
        console.log(res.data)
        this.user = res.data.data;
      })
    },
      deleteUser(id) {
      const api = new ApiService("/user/delete")
      api.getParams({
        id: id,
      }).then(res => {
        if(res.data!=null) {
          this.$message.info("删除成功")
          this.getAlluser()
        }
      })
    }
  }
}
</script>
<style scoped>
  .el-container, .el-timeline-item__node {
    /* display: -webkit-box; */
    display: -ms-flexbox;
    height: 90vh;
  }
  .floor{
    position: relative;
  }
  .el-pagination{
    float: left;
    position: absolute;
    top: 10px;
  }
  .el-button--primary {
    color: #FFF;
    background-color: #409EFF;
    border-color: #409EFF;
    float: right;
    clear: top;
    top: 0px;
    margin-right: 20px;
  }
</style>
